#include "datamanager.h"

// TODO : ??????
DataManager* DataManager::m_data = new DataManager();

// 获取单例对象
DataManager *DataManager::getInstance()
{
    return m_data;
}

// 设置数据
void DataManager::setUserName(QByteArray name)
{
    m_userName = name;
}

void DataManager::setIp(QByteArray ip)
{
    m_ip = ip;
}

void DataManager::setPort(QByteArray port)
{
    m_port = port;
}

void DataManager::setRoomName(QByteArray roomName)
{
    m_roomName = roomName;
}

void DataManager::setCommunication(Communication *communication)
{
    m_communication = communication;
}

void DataManager::setCards(Cards cs, Cards last3Cards)
{
    m_cs = cs;
    m_last3Cards = last3Cards;
}

void DataManager::setGameMode(GameMode mode)
{
    m_mode = mode;
}

void DataManager::setRoomMode(RoomMode mode)
{
    m_roomMode = mode;
}

// 获取数据
QByteArray DataManager::getUserName() const
{
    return m_userName;
}

QByteArray DataManager::getIp() const
{
    return m_ip;
}

QByteArray DataManager::getPort() const
{
    return m_port;
}

QByteArray DataManager::getRoomName() const
{
    return m_roomName;
}

Cards DataManager::getCards() const
{
    return m_cs;
}

Cards DataManager::getLast3Cards() const
{
    return m_last3Cards;
}

bool DataManager::isNetworkMode() const
{
    return m_mode == DataManager::GameMode::Network ? true : false;
}

bool DataManager::isManualMode() const
{
    return m_roomMode == DataManager::RoomMode::Manual ? true : false;
}

Communication* DataManager::getCommunication()const
{
    return m_communication;
}
